#pragma once

#include <iostream>
#include <string>
#include <cstring>
#include <memory>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <vector>
#include<thread>
#include <signal.h>
#include "nocopy.h"

using namespace std;

class Inet_data
{
public:
    Inet_data(int sockfd,const sockaddr_in &tmp)
        : _ip(tmp.sin_addr.s_addr), _port(tmp.sin_port),_sockfd(sockfd),_sock(tmp)
    {}
    
    uint16_t get_port()
    {
        return _port;
    }

    in_addr_t get_ip()
    {
        return _ip;
    }

    bool operator==(const Inet_data &tmp)
    {
        return _ip==tmp._ip&&_port==tmp._port;
    }

    void Inet_info()
    {
        string client_ip = inet_ntoa(_sock.sin_addr);
        uint16_t client_port = ntohs(_port);
        cout << "sock_fd = "<<_sockfd<<" client_ip = " << client_ip << " client_port = " << to_string(_port) << endl;
    }

private:
    int _sockfd;
    sockaddr_in _sock;
    in_addr_t _ip;
    uint16_t _port;
};